/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tech15.task.model;

import java.util.Date;
import java.util.List;

import javacommon.base.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;

import cn.org.rapid_framework.util.DateConvertUtils;

import com.tech15.core.model.Attach;

/**
 * @author 胡作正 email:zuozhenghu@sina.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "TASK")
public class Task extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
//	alias
	public static final String TABLE_ALIAS = "个人办公";
	public static final String ALIAS_TASKID = "序号";
	public static final String ALIAS_SERIAL = "任务编号";
	public static final String ALIAS_TITLE = "主题";
	public static final String ALIAS_CREATER = "发起人";
	public static final String ALIAS_CREATTIME = "创建时间";
	public static final String ALIAS_AUTHTIME = "审核时间";
	public static final String ALIAS_COMPLETTIME = "完成时间";
	public static final String ALIAS_CONTENT = "任务内容";
	public static final String ALIAS_TASKSTATE = "任务状态（0审批中 1完成 2退回）";
	public static final String ALIAS_EXECSTATE = "执行状态（0执行中 1完成）";
	public static final String ALIAS_LB = "类别";
	
	//date formats
	public static final String FORMAT_CREATTIME = DATE_TIME_FORMAT;
	public static final String FORMAT_AUTHTIME = DATE_TIME_FORMAT;
	public static final String FORMAT_COMPLETTIME = DATE_TIME_FORMAT;
	public static final String FORMAT_JHWCSJ = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 序号       db_column: TASKID 
     */ 	
	
	private Long taskid;
    /**
     * 任务编号       db_column: SERIAL 
     */ 	
	@Length(max=100)
	private java.lang.String serial;
    /**
     * 主题       db_column: TITLE 
     */ 	
	@Length(max=200)
	private java.lang.String title;
    /**
     * 发起人       db_column: CREATER 
     */ 	
	
	private Long creater;
    /**
     * 创建时间       db_column: CREATTIME 
     */ 	
	
	private java.util.Date creattime;
    /**
     * 审核时间       db_column: AUTHTIME 
     */ 	
	
	private java.util.Date authtime;
    /**
     * 完成时间       db_column: COMPLETTIME 
     */ 	
	
	private java.util.Date complettime;
    /**
     * 任务内容       db_column: CONTENT 
     */ 	
	@Length(max=800)
	private java.lang.String content;
    /**
     * 任务状态（0审批中 1完成 2退回）       db_column: TASKSTATE 
     */ 	
	@Max(127)
	private Integer taskstate;
    /**
     * 执行状态（0执行中 1完成）       db_column: EXECSTATE 
     */ 	
	@Max(127)
	private Integer execstate;
    /**
     * 类别       db_column: LB 
     */ 	
	
	private Long lb;
	/**
     * 完成时间       db_column: JHWCSJ 
     */ 	
	
	private java.util.Date jhwcsj;
	/**
     * 主送部门联系人       db_column: ZSBMLXR 
     */ 	
	@Length(max=30)
	private java.lang.String zsbmlxr;
	
	/**
     * 退回人       db_column: THR 
     */ 	
	
	private Long thr;
	//columns END


	public Task(){
	}

	public Task(
		Long taskid
	){
		this.taskid = taskid;
	}

	

	public void setTaskid(Long value) {
		this.taskid = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "TASKID", unique = true, nullable = false, insertable = true, updatable = true, length = 22)
	public Long getTaskid() {
		return this.taskid;
	}
	
	@Column(name = "SERIAL", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSerial() {
		return this.serial;
	}
	
	public void setSerial(java.lang.String value) {
		this.serial = value;
	}
	
	@Column(name = "TITLE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getTitle() {
		return this.title;
	}
	
	public void setTitle(java.lang.String value) {
		this.title = value;
	}
	
	@Column(name = "CREATER", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getCreater() {
		return this.creater;
	}
	
	public void setCreater(Long value) {
		this.creater = value;
	}
	
	@Column(name = "THR", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getThr() {
		return this.thr;
	}
	
	public void setThr(Long value) {
		this.thr = value;
	}
	
	@Transient
	public String getCreattimeString() {
		return DateConvertUtils.format(getCreattime(), FORMAT_CREATTIME);
	}
	public void setCreattimeString(String value) {
		setCreattime(DateConvertUtils.parse(value, FORMAT_CREATTIME,java.util.Date.class));
	}
	
	@Column(name = "CREATTIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getCreattime() {
		return this.creattime;
	}
	
	public void setCreattime(java.util.Date value) {
		this.creattime = value;
	}
	
	@Column(name = "JHWCSJ", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getJhwcsj() {
		return this.jhwcsj;
	}
	
	public void setJhwcsj(java.util.Date value) {
		this.jhwcsj = value;
	}
	
	@Transient
	public String getJhwcsjString() {
		return DateConvertUtils.format(getJhwcsj(), FORMAT_JHWCSJ);
	}
	public void setJhwcsjString(String value) {
		setCreattime(DateConvertUtils.parse(value, FORMAT_JHWCSJ,java.util.Date.class));
	}
	
	@Column(name = "ZSBMLXR", unique = false, nullable = true, insertable = true, updatable = true, length = 30)
	public java.lang.String getZsbmlxr() {
		return this.zsbmlxr;
	}
	
	public void setZsbmlxr(java.lang.String value) {
		this.zsbmlxr = value;
	}
	
	@Transient
	public String getAuthtimeString() {
		return DateConvertUtils.format(getAuthtime(), FORMAT_AUTHTIME);
	}
	public void setAuthtimeString(String value) {
		setAuthtime(DateConvertUtils.parse(value, FORMAT_AUTHTIME,java.util.Date.class));
	}
	
	@Column(name = "AUTHTIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getAuthtime() {
		return this.authtime;
	}
	
	public void setAuthtime(java.util.Date value) {
		this.authtime = value;
	}
	
	@Transient
	public String getComplettimeString() {
		return DateConvertUtils.format(getComplettime(), FORMAT_COMPLETTIME);
	}
	public void setComplettimeString(String value) {
		setComplettime(DateConvertUtils.parse(value, FORMAT_COMPLETTIME,java.util.Date.class));
	}
	
	@Column(name = "COMPLETTIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getComplettime() {
		return this.complettime;
	}
	
	public void setComplettime(java.util.Date value) {
		this.complettime = value;
	}
	
	@Column(name = "CONTENT", unique = false, nullable = true, insertable = true, updatable = true, length = 800)
	public java.lang.String getContent() {
		return this.content;
	}
	
	public void setContent(java.lang.String value) {
		this.content = value;
	}
	
	@Column(name = "TASKSTATE", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getTaskstate() {
		return this.taskstate;
	}
	
	public void setTaskstate(Integer value) {
		this.taskstate = value;
	}
	
	@Column(name = "EXECSTATE", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getExecstate() {
		return this.execstate;
	}
	
	public void setExecstate(Integer value) {
		this.execstate = value;
	}
	
	@Column(name = "LB", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getLb() {
		return this.lb;
	}
	
	public void setLb(Long value) {
		this.lb = value;
	}
	
	

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Taskid",getTaskid())
			.append("Serial",getSerial())
			.append("Title",getTitle())
			.append("Creater",getCreater())
			.append("Creattime",getCreattime())
			.append("Complettime",getComplettime())
			.append("Content",getContent())
			.append("Taskstate",getTaskstate())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getTaskid())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Task == false) return false;
		if(this == obj) return true;
		Task other = (Task)obj;
		return new EqualsBuilder()
			.append(getTaskid(),other.getTaskid())
			.isEquals();
	}
	
	private Long tpid;
	private Date tasktime;
	private Long executor;
	private String hanldresult;
	private String username;
	private Long hanlder;
	private String dataname;
	private Integer hanldestate;
	private Integer opttype;
	private Integer mycls;
	
	
	private List<TaskProcess> taskProcessList;
	private List<Attach> attach;
	
	private String creattimeBegin;
	private String creattimeEnd;
	
	private TaskProcess tp;
	private Long[] deptids;
	private Integer taskaction;
	private List<TaskDept> taskdepts;
	private Long[] sendDeptids;
	private List<TaskDept> taskSendDepts;
	private Long[] execUsers;
	private String optHanldresult;
	
	private String tel;
	private String phone;
	private String shrxm;
	private String sprxm;
	private String thrxm;
	
	private Integer spcs;
	private String deptname;
	private Long xmspr;
	
	@Transient
	public Long getXmspr() {
		return xmspr;
	}

	public void setXmspr(Long xmspr) {
		this.xmspr = xmspr;
	}

	@Transient
	public String getDeptname() {
		return deptname;
	}

	public void setDeptname(String deptname) {
		this.deptname = deptname;
	}

	@Transient
	public Integer getSpcs() {
		return spcs;
	}

	public void setSpcs(Integer spcs) {
		this.spcs = spcs;
	}

	@Transient
	public String getThrxm() {
		return thrxm;
	}

	public void setThrxm(String thrxm) {
		this.thrxm = thrxm;
	}

	@Transient
	public String getShrxm() {
		return shrxm;
	}

	public void setShrxm(String shrxm) {
		this.shrxm = shrxm;
	}

	@Transient
	public String getSprxm() {
		return sprxm;
	}

	public void setSprxm(String sprxm) {
		this.sprxm = sprxm;
	}

	@Transient
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Transient
	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@Transient
	public String getOptHanldresult() {
		return optHanldresult;
	}

	public void setOptHanldresult(String optHanldresult) {
		this.optHanldresult = optHanldresult;
	}

	@Transient
	public Long[] getExecUsers() {
		return execUsers;
	}

	public void setExecUsers(Long[] execUsers) {
		this.execUsers = execUsers;
	}

	@Transient
	public List<TaskDept> getTaskSendDepts() {
		return taskSendDepts;
	}

	public void setTaskSendDepts(List<TaskDept> taskSendDepts) {
		this.taskSendDepts = taskSendDepts;
	}

	@Transient
	public Long[] getSendDeptids() {
		return sendDeptids;
	}

	public void setSendDeptids(Long[] sendDeptids) {
		this.sendDeptids = sendDeptids;
	}

	@Transient
	public List<TaskDept> getTaskdepts() {
		return taskdepts;
	}

	public void setTaskdepts(List<TaskDept> taskdepts) {
		this.taskdepts = taskdepts;
	}

	@Transient
	public Integer getTaskaction() {
		return taskaction;
	}

	public void setTaskaction(Integer taskaction) {
		this.taskaction = taskaction;
	}

	@Transient
	public Long[] getDeptids() {
		return deptids;
	}

	public void setDeptids(Long[] deptids) {
		this.deptids = deptids;
	}

	@Transient
	public TaskProcess getTp() {
		return tp;
	}

	public void setTp(TaskProcess tp) {
		this.tp = tp;
	}

	@Transient
	public String getCreattimeBegin() {
		return creattimeBegin;
	}

	public void setCreattimeBegin(String creattimeBegin) {
		this.creattimeBegin = creattimeBegin;
	}

	@Transient
	public String getCreattimeEnd() {
		return creattimeEnd;
	}

	public void setCreattimeEnd(String creattimeEnd) {
		this.creattimeEnd = creattimeEnd;
	}

	@Transient
	public List<Attach> getAttach() {
		return attach;
	}

	public void setAttach(List<Attach> attach) {
		this.attach = attach;
	}
	
	@Transient
	public List<TaskProcess> getTaskProcessList() {
		return taskProcessList;
	}

	public void setTaskProcessList(List<TaskProcess> taskProcessList) {
		this.taskProcessList = taskProcessList;
	}

	@Transient
	public Integer getHanldestate() {
		return hanldestate;
	}

	public void setHanldestate(Integer hanldestate) {
		this.hanldestate = hanldestate;
	}

	@Transient
	public String getDataname() {
		return dataname;
	}

	public void setDataname(String dataname) {
		this.dataname = dataname;
	}

	@Transient
	public Long getHanlder() {
		return hanlder;
	}

	public void setHanlder(Long hanlder) {
		this.hanlder = hanlder;
	}

	@Transient
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Transient
	public String getHanldresult() {
		return hanldresult;
	}

	public void setHanldresult(String hanldresult) {
		this.hanldresult = hanldresult;
	}

	@Transient
	public Long getExecutor() {
		return executor;
	}

	public void setExecutor(Long executor) {
		this.executor = executor;
	}

	@Transient
	public Date getTasktime() {
		return tasktime;
	}

	public void setTasktime(Date tasktime) {
		this.tasktime = tasktime;
	}

	@Transient
	public Long getTpid() {
		return tpid;
	}

	public void setTpid(Long tpid) {
		this.tpid = tpid;
	}

	@Transient
	public Integer getOpttype() {
		return opttype;
	}

	public void setOpttype(Integer opttype) {
		this.opttype = opttype;
	}

	@Transient
	public Integer getMycls() {
		return mycls;
	}

	public void setMycls(Integer mycls) {
		this.mycls = mycls;
	}
	
}

